home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 1.6 KB | 39 lines | [TEXT/GEOL] |
- Item 1474188 22-July-89 22:56
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: CDA0004 VAR Shana Enterprises, Don Murphy
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: re There really is a bug…
-
- After thinking about this, I agree that there is a compiler bug. But the bug
- is that the compiler allows you to pass the result of a cast as a VAR
- parameter. I think the compiler should report this as an error.
-
- A cast should be considered a function call that transforms the value. For
- example, you can cast an INTEGER into a LONGINT, and this involves a
- computation. Now, it is true that for Object Pascal (as currently defined) an
- object cast does not change the object reference. In C++ this is not true; a
- cast can even involve creating a new object.
-
- In the examples given by Wayne, the cast is unnecessary in both test
- procedures. If you remove the casts, then the compiler does what you would
- expect.
-
- This reveals another compiler bug. The compiler allows you to pass a TBar
- object to a procedure that expects a VAR TFoo object (where TBar is a subclass
- of TFoo). This should be reported as a compiler error, because it allows you
- to assign a TFoo object to a variable declared as a TBar. Since a VAR
- parameter is both an input and an output, the compiler should require that you
- pass exactly the same type.
-
- Defining a MakeFoo procedure what accepts a VAR parameter is perfectly legal.
- You would be able to use this procedure to allocate objects, but you would have
- to pass variables declared as TFoo.
-
- Larry
-
-
-